package main

import (
	"net/http"

	"github.com/julienschmidt/httprouter"
)

// 使用第三方的router
func main() {
	router := httprouter.New()
	router.GET("/", Index)
	router.GET("/hello/:name", Hello)

	http.ListenAndServe(":8080", router)
}

func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	w.Write([]byte("index...."))
	// fmt.Fprint(w, "index...")
}

func Hello(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
	w.Write([]byte("hello...." + params.ByName("name")))
	// fmt.Fprintf(w, "hello, %s", params.ByName("name"))
}
